import {UPDATECITY} from "./mutation-types";
import { Indicator } from 'mint-ui';

export default {
  [UPDATECITY] (state, { city }) {
    if (city.name) {//将从actions传递过来的city参数接收过来，判断有没有name，默认为北京
      state.name = city.name
      state.data = city.data
      state.rN = city.rN
    }
    state.show = false
  },
  showCityList (state) {
    state.show = true
  },
  pushLoadStack (state) {
    Indicator.open({//调用mint-ui里的Indicator加载器
      text: 'loading...',//loading的文本
      spinnerType: 'snake'//loading的样式
    });
    state.stack.push(1)//向state.stack数组中末尾添加1
  },
  completeLoad (state) {//loading结束时，将state.stack中的末尾一个元素删除
    let stack = state.stack
    stack.pop()
    if (!stack.length) {
      //延时为了更好显示loading效果
      setTimeout(() => {
        Indicator.close()
      }, 200)
    }
  },
  pushComingList (state, { lists }) {
    state.lists = lists
  },
  playVideo (state, { audio }) {
    state.url = audio.url
    state.cover = audio.cover
    state.playStatus = true
  },
  pauseVideo (state) {
    state.playStatus = false
  },
  updateAreaData (state, { area }) {
    state.area = area
  }
}
